package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.*;
import com.ssy.lingxi.system.dto.response.MiddlegroundMenuResponse;
import com.ssy.lingxi.system.service.MiddlegroundMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @menu 权限管理-中台权限菜单管理
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "中台权限菜单管理")
@RestController
public class MiddlegroundMenuController {


    @Autowired
    MiddlegroundMenuService menuService;


    @ApiOperation(value = " 查询权限菜单列表")
    @GetMapping("/middleground/menu/list")
    public Wrapper<List<MiddlegroundMenuResponse>> menuList() {
        return menuService.menuList();
    }

    @ApiOperation(value = " 添加权限菜单")
    @PostMapping("/middleground/menu/add")
    public Wrapper menuAdd(@RequestBody  MiddlegroundMenuAddRequest request,HttpServletRequest httpServletRequest) {
        return menuService.menuAdd(request,httpServletRequest);
    }


    @ApiOperation(value = " 修改权限菜单")
    @PostMapping("/middleground/menu/update")
    public Wrapper menuUpdate(@RequestBody MiddlegroundMenuUpdateRequest request) {
        return menuService.menuUpdate(request);
    }

    @ApiOperation(value = " 删除权限菜单")
    @PostMapping("/middleground/menu/delete")
    public Wrapper menuDelete(@RequestBody MiddlegroundMenuDeleteRequest request) {
        return menuService.menuDelete(request);
    }


    @ApiOperation(value = " 根据角色ID查询权限菜单列表")
    @GetMapping("/middleground/menu/role/list")
    public Wrapper<List<MiddlegroundMenuResponse>> menuListByRoleId(HttpServletRequest request) {
        return menuService.menuListByRoleId(request);
    }

    @ApiOperation(value = "配置会员权限")
    @PostMapping("/middleground/menu/role/binding")
    public Wrapper menuRoleBinding(@RequestBody MenuBindingRoleRequest request) {
        return menuService.menuRoleBinding(request);
    }


    @ApiOperation(value = "根据菜单ID查询菜单详情")
    @GetMapping("/middleground/menu/details")
    public Wrapper<MiddlegroundMenuUpdateRequest> menuDetails(MenuDetailsRequest request) {
        return menuService.menuDetails(request);
    }

}
